﻿using System;
using SharpSqlAnalyzer.nodes;

namespace SharpSqlAnalyzer.stmt.mysql
{
	// Token: 0x02000151 RID: 337
	public class TMySQLCreateFunction : TStoredProcedureSqlStatement
	{
		// Token: 0x06000B4C RID: 2892 RVA: 0x00305D1B File Offset: 0x00303F1B
		public TMySQLCreateFunction(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstmysqlcreatefunction;
		}

		// Token: 0x06000B4D RID: 2893 RVA: 0x00305D2F File Offset: 0x00303F2F
		internal override void buildsql()
		{
		}

		// Token: 0x06000B4E RID: 2894 RVA: 0x00305D31 File Offset: 0x00303F31
		internal override void clear()
		{
		}

		// Token: 0x06000B4F RID: 2895 RVA: 0x00305D33 File Offset: 0x00303F33
		internal override string getasprettytext()
		{
			return "";
		}

		// Token: 0x06000B50 RID: 2896 RVA: 0x00305D3A File Offset: 0x00303F3A
		internal virtual void iterate(TVisitorAbs pvisitor)
		{
		}

		// Token: 0x17000210 RID: 528
		// (get) Token: 0x06000B51 RID: 2897 RVA: 0x00305D3C File Offset: 0x00303F3C
		public override TObjectName StoredProcedureName
		{
			get
			{
				return this.functionName;
			}
		}

		// Token: 0x17000211 RID: 529
		// (get) Token: 0x06000B52 RID: 2898 RVA: 0x00305D44 File Offset: 0x00303F44
		// (set) Token: 0x06000B53 RID: 2899 RVA: 0x00305D4C File Offset: 0x00303F4C
		public virtual TTypeName ReturnDataType
		{
			get
			{
				return this.returnDataType;
			}
			set
			{
				this.returnDataType = value;
			}
		}

		// Token: 0x17000212 RID: 530
		// (get) Token: 0x06000B54 RID: 2900 RVA: 0x00305D55 File Offset: 0x00303F55
		// (set) Token: 0x06000B55 RID: 2901 RVA: 0x00305D5D File Offset: 0x00303F5D
		public virtual TObjectName FunctionName
		{
			get
			{
				return this.functionName;
			}
			set
			{
				this.functionName = value;
			}
		}

		// Token: 0x06000B56 RID: 2902 RVA: 0x00305D68 File Offset: 0x00303F68
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			TCreateFunctionSqlNode tcreateFunctionSqlNode = (TCreateFunctionSqlNode)this.rootNode;
			base.doParseStatement(psql);
			this.functionName = tcreateFunctionSqlNode.FunctionName;
			base.DatabaseObjects.Add(this.functionName);
			this.ParameterDeclarations = tcreateFunctionSqlNode.Parameters;
			if (this.ParameterDeclarations != null)
			{
				for (int i = 0; i < this.ParameterDeclarations.size(); i++)
				{
					this.TopStatement.SymbolTable.Push(new TSymbolTableItem(9, this, this.ParameterDeclarations.getParameterDeclarationItem(i)));
				}
			}
			this.returnDataType = tcreateFunctionSqlNode.ReturnDataType;
			if (tcreateFunctionSqlNode.Stmt != null)
			{
				tcreateFunctionSqlNode.Stmt.doParse(this, ESqlClause.unknown);
				this.BodyStatements.add(tcreateFunctionSqlNode.Stmt.Stmt);
			}
			else if (tcreateFunctionSqlNode.Blcok != null)
			{
				tcreateFunctionSqlNode.Blcok.Stmts.doParse(this, ESqlClause.unknown);
				for (int j = 0; j < tcreateFunctionSqlNode.Blcok.Stmts.size(); j++)
				{
					this.BodyStatements.add(tcreateFunctionSqlNode.Blcok.Stmts.getStatementSqlNode(j).Stmt);
				}
			}
			if (this.ParameterDeclarations != null)
			{
				for (int k = 0; k < this.ParameterDeclarations.size(); k++)
				{
					this.TopStatement.SymbolTable.Pop();
				}
			}
			return 0;
		}

		// Token: 0x06000B57 RID: 2903 RVA: 0x00305EBD File Offset: 0x003040BD
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x06000B58 RID: 2904 RVA: 0x00305ECD File Offset: 0x003040CD
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			if (this.ParameterDeclarations != null)
			{
				this.ParameterDeclarations.acceptChildren(v);
			}
			this.BodyStatements.acceptChildren(v);
			v.postVisit(this);
		}

		// Token: 0x040012AD RID: 4781
		private TTypeName returnDataType;

		// Token: 0x040012AE RID: 4782
		private TObjectName functionName;
	}
}
